//
//  WHZAfnetWorking.m
//  MyProject
//
//  Created by dllo on 15/10/31.
//  Copyright (c) 2015年 蓝鸥0825. All rights reserved.
//

#import "WHZAfnetWorking.h"
#import <AFNetworking.h>

@implementation WHZAfnetWorking

+ (void)GETJRAfnNetworkingWithUrl:(NSString *)url WithParameters:(NSDictionary *)para Block:(void (^)(id))block {
    AFHTTPRequestOperationManager *mannager = [AFHTTPRequestOperationManager manager];
    [mannager.responseSerializer setAcceptableContentTypes: [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html",@"text/css",@"text/plain", nil]];
    
    [mannager GET:url parameters:para success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        block(responseObject);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
//        UIAlertView *alterView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"您当前网络不佳" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
//        [alterView show];
        NSLog(@"%@",error);
        
        
    }];
    
}

+ (void)POSTJRAfnNetworkingWithUrl:(NSString *)url WithParameters:(NSDictionary *)para Block:(void (^)(id result))block{
    
    AFHTTPRequestOperationManager *netManager = [AFHTTPRequestOperationManager manager];
    netManager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain",@"text/json",@"application/json",@"text/javascript",@"text/html",nil];
    
    [netManager POST:url parameters:para success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        block(responseObject);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        UIAlertView *alterView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"您当前网络不佳" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
        [alterView show];
        NSLog(@"失败==== %@",error);
        
    }];
}

@end
